package com.cyzy.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

import java.util.Date;

@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class User {
    private Integer id;
    private Integer username;
    private String password;
    private String phone;
    private String nickname;
    private String avatar;
    private Integer gender; // 1-男 2-女
    private Integer age;
    private Integer role; // 1-老师 2-学生
    private String realName;
    private String idCard;
    private Integer realNameVerified; // 0-未认证 1-已认证

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;
    private Integer classId;

    // 用于前端显示的转换字段
    public String getRoleStr() {
        return role == null ? "" : (role == 1 ? "老师" : "学生");
    }

    public String getGenderStr() {
        if (gender == null) return "";
        return gender == 1 ? "男" : "女";
    }

    public String getRealNameVerifiedStr() {
        if (realNameVerified == null) return "否";
        return realNameVerified == 1 ? "是" : "否";
    }
}